package com.tuobuxie.entity;
// Generated 2016-11-24 15:23:31 by Hibernate Tools 4.3.4.Final

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.alibaba.fastjson.JSON;


/**
 * TShoppingCart generated by hbm2java
 */
@Entity
@Table(name = "T_SHOPPING_CART", schema = "TUOBUXIE")
public class TShoppingCart implements java.io.Serializable {

	private Integer CId;
	private BigDecimal CGoodsId;
	private BigDecimal CQuantity;
	private List<TItem> tItems =new ArrayList<TItem>();

	@OneToMany(mappedBy="tShoppingCart" ,fetch = FetchType.EAGER,cascade = CascadeType.ALL)

	public List<TItem> gettItems() {
		return tItems;
	}

	public void settItems(List<TItem> tItems) {
		this.tItems = tItems;
	}

	public void addShoppingItem(TItem item)
	{
		item.settShoppingCart(this);
		tItems.add(item);
	}




	public TShoppingCart() {
	}
	public TShoppingCart(Integer CId) {
		this.CId = CId;
	}

	public TShoppingCart(Integer CId, BigDecimal CGoodsId, BigDecimal CQuantity) {
		this.CId = CId;
		this.CGoodsId = CGoodsId;
		this.CQuantity = CQuantity;
	}

	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="S_TShoppingCart")
	@SequenceGenerator(name="S_TShoppingCart", allocationSize=1, initialValue=1,sequenceName="S_TShoppingCart")
	@Column(name = "C_ID", unique = true, nullable = false, precision = 22, scale = 0)
	public Integer getCId() {
		return this.CId;
	}

	public void setCId(Integer CId) {
		this.CId = CId;
	}

	@Column(name = "C_GOODS_ID", precision = 22, scale = 0)
	public BigDecimal getCGoodsId() {
		return this.CGoodsId;
	}

	public void setCGoodsId(BigDecimal CGoodsId) {
		this.CGoodsId = CGoodsId;
	}

	@Column(name = "C_QUANTITY", precision = 22, scale = 0)
	public BigDecimal getCQuantity() {
		return this.CQuantity;
	}

	public void setCQuantity(BigDecimal CQuantity) {
		this.CQuantity = CQuantity;
	}
	@Override
	public String toString() {

		return JSON.toJSONString(this);
	}
}